﻿// CurveSetDlg.cpp : 实现文件
//

#include "stdafx.h"
#include "HC-MG.h"
#include "CurveSetDlg.h"
#include "afxdialogex.h"
#include "PrintSetDlg.h"
#include "UI/MultiLanguage.h"
// CCurveSetDlg 对话框

IMPLEMENT_DYNAMIC(CCurveSetDlg, CDialogEx)

CCurveSetDlg::CCurveSetDlg(CWnd* pParent /*=NULL*/)
	: CDialogEx(CCurveSetDlg::IDD, pParent)
	, m_nCurvePrint(0)
	, m_nCurveScale(0)
{
	m_brush.CreateSolidBrush(RGB(255, 255, 255));
}

CCurveSetDlg::~CCurveSetDlg()
{
	m_brush.DeleteObject();
}

void CCurveSetDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_CHK_QS, m_chkQs);
	DDX_Control(pDX, IDC_CHK_SLGQ, m_chkSlgq);
	DDX_Radio(pDX, IDC_RADIO_CURVE_SIMPLE_PRINT, m_nCurvePrint);
	DDX_Radio(pDX, IDC_RADIO_SCALE_3_2, m_nCurveScale);
}


BEGIN_MESSAGE_MAP(CCurveSetDlg, CDialogEx)
	ON_WM_CTLCOLOR()
	ON_WM_NCDESTROY()
	ON_WM_PAINT()
	ON_BN_CLICKED(IDC_RADIO_CURVE_SIMPLE_PRINT, &CCurveSetDlg::OnBnClickedRadioCurveSimplePrint)
	ON_BN_CLICKED(IDC_RADIO_QS_SLGT_PRINT, &CCurveSetDlg::OnBnClickedRadioCurveSimplePrint)
	ON_BN_CLICKED(IDC_RADIO_SCALE_3_2, &CCurveSetDlg::OnBnClickedRadioScale32)
	ON_BN_CLICKED(IDC_RADIO_SCALE_1_1, &CCurveSetDlg::OnBnClickedRadioScale32)
	ON_BN_CLICKED(IDC_CHK_QS, &CCurveSetDlg::OnBnClickedChkQs)
	ON_BN_CLICKED(IDC_CHK_SLGQ, &CCurveSetDlg::OnBnClickedChkSlgq)
END_MESSAGE_MAP()


// CCurveSetDlg 消息处理程序


BOOL CCurveSetDlg::PreTranslateMessage(MSG* pMsg)
{
	if (pMsg->message == WM_KEYDOWN)
	{
		switch (pMsg->wParam)
		{
		case VK_ESCAPE:
			return TRUE;
		case VK_RETURN:
			return TRUE;
		default:
			break;
		}
	}
	return CDialogEx::PreTranslateMessage(pMsg);
}


BOOL CCurveSetDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();
	g_SetDialogStrings(this, IDD);
	return TRUE;  
}

//初始化数据
void CCurveSetDlg::InitData(PRINT_SET &PrintSet)
{	
	m_nCurvePrint = PrintSet.chCurvePrintStype;
	if (g_DataType != DATA_1)
	{
		m_chkSlgq.EnableWindow(FALSE);
		m_chkSlgq.SetCheck(0);
		((CButton *)GetDlgItem(IDC_RADIO_CURVE_SIMPLE_PRINT))->EnableWindow(FALSE);
		((CButton *)GetDlgItem(IDC_RADIO_QS_SLGT_PRINT))->EnableWindow(FALSE);
		m_nCurvePrint = PrintSet.chCurvePrintStype = 0;
	}

	if (0 == m_nCurvePrint)
	{
		((CButton *)GetDlgItem(IDC_RADIO_CURVE_SIMPLE_PRINT))->SetCheck(TRUE);
		((CButton *)GetDlgItem(IDC_RADIO_QS_SLGT_PRINT))->SetCheck(FALSE);
	}
	else if (1 == m_nCurvePrint)
	{
		((CButton *)GetDlgItem(IDC_RADIO_CURVE_SIMPLE_PRINT))->SetCheck(FALSE);
		((CButton *)GetDlgItem(IDC_RADIO_QS_SLGT_PRINT))->SetCheck(TRUE);
	}

	m_nCurveScale = PrintSet.chScale;
	if (0 == m_nCurveScale)
	{
		((CButton *)GetDlgItem(IDC_RADIO_SCALE_3_2))->SetCheck(TRUE);
		((CButton *)GetDlgItem(IDC_RADIO_SCALE_1_1))->SetCheck(FALSE);
	}
	else
	{
		((CButton *)GetDlgItem(IDC_RADIO_SCALE_3_2))->SetCheck(FALSE);
		((CButton *)GetDlgItem(IDC_RADIO_SCALE_1_1))->SetCheck(TRUE);
	}

	if (g_DataType != DATA_1)
	{
		PrintSet.chSlgQ = 0;
	}
	m_chkQs.SetCheck(PrintSet.chQs);
	m_chkSlgq.SetCheck(PrintSet.chSlgQ);

//	SetCurveStyle();
}

//获取数据
void CCurveSetDlg::GetData(PRINT_SET &PrintSet)
{
	UpdateData(TRUE);
	PrintSet.chCurvePrintStype = m_nCurvePrint;
	PrintSet.chScale = m_nCurveScale;
	PrintSet.chQs = m_chkQs.GetCheck();
	PrintSet.chSlgQ = m_chkSlgq.GetCheck();
}


HBRUSH CCurveSetDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
	HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);

	switch (nCtlColor)
	{
	case CTLCOLOR_STATIC:
		pDC->SetBkMode(1);
		return m_brush;
		break;
	}
	return hbr;
}


void CCurveSetDlg::OnNcDestroy()
{
	CDialogEx::OnNcDestroy();
	delete this;
}


void CCurveSetDlg::OnPaint()
{
	CPaintDC dc(this);
	CRect rt;
	GetClientRect(&rt);
	dc.FillSolidRect(rt, RGB(255, 255, 255));
}


void CCurveSetDlg::SetCurveStyle()
{
	UpdateData(TRUE);
// 	switch (m_nCurvePrint)
// 	{
// 	case 0:
// 		m_chkQs.EnableWindow(TRUE);
// 		m_chkSlgq.EnableWindow(TRUE);
// 		m_chkSlgt.EnableWindow(TRUE);
// 		break;
// 	case 1:
// 		if (g_DataType == DATA_0)
// 		{
// 			m_chkQs.EnableWindow(FALSE);
// 			m_chkQs.SetCheck(1);
// 			g_PrintSet.chQs = 1;
// 			m_chkSlgt.EnableWindow(FALSE);
// 			m_chkSlgt.SetCheck(1);
// 			g_PrintSet.chSlgt = 1;
// 			m_chkSlgq.EnableWindow(TRUE);
// 		}
// 		else if (g_DataType == DATA_1 || g_DataType == DATA_1)
// 		{
// 			m_chkQs.EnableWindow(FALSE);
// 			m_chkQs.SetCheck(1);
// 			g_PrintSet.chQs = 1;
// 			m_chkSlgq.EnableWindow(FALSE);
// 			m_chkSlgq.SetCheck(1);
// 			g_PrintSet.chSlgQ = 1;
// 		}
// 		break;
// 	case 2:
// 		m_chkSlgq.EnableWindow(FALSE);
// 		m_chkSlgq.SetCheck(1);
// 		g_PrintSet.chSlgQ = 1;
// 		m_chkSlgt.EnableWindow(FALSE);
// 		m_chkSlgt.SetCheck(1);
// 		g_PrintSet.chSlgt = 1;
// 		m_chkQs.EnableWindow(TRUE);
// 		break;
// 	case 3:
// 		m_chkQs.EnableWindow(FALSE);
// 		m_chkQs.SetCheck(1);
// 		g_PrintSet.chQs = 1;
// 		m_chkSlgq.EnableWindow(FALSE);
// 		m_chkSlgq.SetCheck(1);
// 		g_PrintSet.chSlgQ = 1;
// 		m_chkSlgt.EnableWindow(FALSE);
// 		m_chkSlgt.SetCheck(1);
// 		g_PrintSet.chSlgt = 1;
// 		break;
// 	default:
// 		break;
// 	}
	g_PrintSet.chCurvePrintStype = m_nCurvePrint;
}

void CCurveSetDlg::OnBnClickedRadioCurveSimplePrint()
{
	UpdateData(TRUE);
	SetCurveStyle();
	CPrintSetDlg::m_pstWnd->DrawPage();
}


void CCurveSetDlg::OnBnClickedRadioScale32()
{
	UpdateData(TRUE);
	switch (m_nCurveScale)
	{
	case 0:
		g_PrintSet.chScale = 0;
		CPrintSetDlg::m_pstWnd->DrawPage();
		break;
	case 1:
		g_PrintSet.chScale = 1;
		CPrintSetDlg::m_pstWnd->DrawPage();
		break;
	default:
		break;
	}
}


void CCurveSetDlg::OnBnClickedChkQs()
{
	g_PrintSet.chQs = m_chkQs.GetCheck();
	CPrintSetDlg::m_pstWnd->DrawPage();
}


void CCurveSetDlg::OnBnClickedChkSlgq()
{
	g_PrintSet.chSlgQ = m_chkSlgq.GetCheck();
	CPrintSetDlg::m_pstWnd->DrawPage();
}
